{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## 第五次练习"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "+ 请务必交到exer5文件夹下，**谢绝交到master下**\n",
    "+ 请不要改动任何文件，拜托\n",
    "+ 请在11月7日前提交。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "请写一下姓名和学号：\n",
    "+ 姓名  汪雅岚\n",
    "+ 学号  0165218"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目一、贫困户模型\n",
    "+ 创建一个类，包含贫困户的义务教育保障、住房安全、饮水安全、肉蛋奶豆的四个属性\n",
    "+ 包含一个是否贫困的预测，如果四个属性有两个以上没有保障（>2)则输出为贫困户\n",
    "+ 对贫困户，采取相应措施（输入参数）对其进行帮扶，使其脱贫\n",
    "+ 至少生成三个实例\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "贫困户\n",
      "给予义务教育保障\n",
      "给予住房安全保障\n",
      "给予饮水安全保障\n",
      "给予食品安全保障\n",
      "\n",
      "贫困户\n",
      "给予义务教育保障\n",
      "给予住房安全保障\n",
      "给予饮水安全保障\n",
      "\n",
      "不是贫困户\n",
      "不需要扶贫\n",
      "\n",
      "不是贫困户\n",
      "不需要扶贫\n",
      "\n",
      "不是贫困户\n",
      "不需要扶贫\n"
     ]
    }
   ],
   "source": [
    "class pinkunhu(object):\n",
    "    def __init__(self,x1,x2,x3,x4):\n",
    "        self.yiwujiaoyubaozhang =x1\n",
    "        self.zhufanganquan = x2\n",
    "        self.yinshuianquan = x3\n",
    "        self.roudannaidou = x4\n",
    "    def zonghe(self):\n",
    "        s=0\n",
    "        if self.yiwujiaoyubaozhang:\n",
    "            s=s+1\n",
    "        if self.zhufanganquan:\n",
    "            s=s+1\n",
    "        if self.yinshuianquan:\n",
    "            s=s+1\n",
    "        if self.roudannaidou:\n",
    "            s=s+1\n",
    "        if s>=2:\n",
    "            print(\"\\n不是贫困户\")\n",
    "        if s<2:\n",
    "            print(\"\\n贫困户\")\n",
    "            if self.yiwujiaoyubaozhang==False:\n",
    "                print(\"给予义务教育保障\")\n",
    "            if self.zhufanganquan==False:\n",
    "                print(\"给予住房安全保障\")\n",
    "            if self.yinshuianquan==False:\n",
    "                print(\"给予饮水安全保障\")\n",
    "            if self.roudannaidou==False:\n",
    "                print(\"给予食品安全保障\")\n",
    "        else:\n",
    "            print(\"不需要扶贫\")\n",
    "jiating1=pinkunhu(False,False,False,False)\n",
    "jiating1.zonghe()\n",
    "jiating1=pinkunhu(False,False,False,True)\n",
    "jiating1.zonghe()\n",
    "jiating1=pinkunhu(False,False,True,True)\n",
    "jiating1.zonghe()\n",
    "jiating1=pinkunhu(False,True,True,True)\n",
    "jiating1.zonghe()\n",
    "jiating1=pinkunhu(True,True,True,True)\n",
    "jiating1.zonghe()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目二: 学生信息\n",
    "+ 创建一个类，包含姓名、分数、睡眠时间三个属性\n",
    "+ 包含一个胖瘦的预测，如果分数>90，且睡眠时间少于6小时，输出“BMI可能偏大”，否则输出“体重正常”\n",
    "+ 为使得标准（90分、6小时）可以调整，标准应设为输入的参数\n",
    "+ 至少生成三个实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "体重正常\n"
     ]
    }
   ],
   "source": [
    "class xuesheng(object):\n",
    "    def __init__(self, xm, fs,sm):\n",
    "            self.xm = xm\n",
    "            self.fs = fs\n",
    "            self.sm = sm\n",
    "    def ddfs(self):           \n",
    "        if self.fs>90 and self.sm <6:\n",
    "            print(\"BMI可能偏大\")\n",
    "        else:\n",
    "            print(\"体重正常\")\n",
    "    \n",
    "xuesheng1 = xuesheng('路人甲',60,12)\n",
    "xuesheng1.ddfs()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "体重正常\n"
     ]
    }
   ],
   "source": [
    "xuesheng2 = xuesheng('路人乙',92,7)\n",
    "xuesheng2.ddfs()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "BMI可能偏大\n"
     ]
    }
   ],
   "source": [
    "xuesheng3 = xuesheng('路人丙',100,5)\n",
    "xuesheng3.ddfs()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### 题目三：“跑步社”成员类\n",
    "+ 创建一个“跑步社”成员类，以学生信息类为父类\n",
    "+ 添加一个属性为跑步\n",
    "+ 如果跑步时间大于30分钟，如果之前预测为“BMI可能偏大”，则输出为“趋向正常”\n",
    "+ 至少生成三个实例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "\t体重正常\n",
      "\n",
      "\t体重正常\n",
      "\n",
      "\tBMI可能偏大\n",
      "\t趋向正常\n",
      "\n",
      "\tBMI可能偏大\n"
     ]
    }
   ],
   "source": [
    "class paobushe(xuesheng):\n",
    "    \n",
    "    def __init__(self,xm,fs,sm,pbsj):\n",
    "        super().__init__(xm,fs,sm)\n",
    "        self.pbsj=pbsj\n",
    "        \n",
    "    def ddfs(self):\n",
    "        if self.fs>90 and self.sm<6:\n",
    "            print('\\n\\tBMI可能偏大')\n",
    "            if self.pbsj>30:\n",
    "                print('\\t趋向正常')\n",
    "        else:\n",
    "            print('\\n\\t体重正常')     \n",
    "            \n",
    "xuesheng1 = paobushe('路人甲',60,12,15)\n",
    "xuesheng1.ddfs()\n",
    "xuesheng2 = paobushe('路人乙',92,6,25)\n",
    "xuesheng2.ddfs()\n",
    "xuesheng3 = paobushe('路人丙',100,5,31)\n",
    "xuesheng3.ddfs()\n",
    "xuesheng4 = paobushe('路人丁',95,4,30)\n",
    "xuesheng4.ddfs()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
